using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using SlimDX;
using SlimDX.Direct3D9;

namespace Splino.D3D
{
    /// <summary>
    /// Describes the elements of different vertex types
    /// </summary>
    public class CustomVertex
    {
        /// <summary>
        /// Describes a vertex that contains a 3D position and integer color
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        public struct PositionColored
        {
            /// <summary>
            /// The 3D position of the vertex
            /// </summary>
            public Vector3 Position;
            /// <summary>
            /// The color of the vertex
            /// </summary>
            public int Color;
            /// <summary>
            /// Gets or sets the X coordinates of the vertex's position
            /// </summary>
            public float X { get { return Position.X; } set { Position.X = value; } }
            /// <summary>
            /// Gets or sets the Y coordinate of the vertex's position
            /// </summary>
            public float Y { get { return Position.Y; } set { Position.Y = value; } }
            /// <summary>
            /// Gets or sets the Z coordinate of the vertex's position
            /// </summary>
            public float Z { get { return Position.Z; } set { Position.Z = value; } }
            /// <summary>
            /// Gets the vertex's format
            /// </summary>
            public static readonly VertexFormat Format = VertexFormat.Diffuse | VertexFormat.Position;
            /// <summary>
            /// Gets the amount of memory the vertex consumes in bytes
            /// </summary>
            public static int SizeInBytes { get { return Marshal.SizeOf(typeof(CustomVertex.PositionColored)); } }
        }
        /// <summary>
        /// Describes a vertex that contains a 3D position
        /// </summary>
        public struct PositionOnly
        {
            /// <summary>
            /// The 3D position of the vertex
            /// </summary>
            public Vector3 Position;
            /// <summary>
            /// Gets or sets the X coordinate of the vertex's position
            /// </summary>
            public float X { get { return Position.X; } set { Position.X = value; } }
            /// <summary>
            /// Gets or sets the Y coordinate of the vertex's position
            /// </summary>
            public float Y { get { return Position.Y; } set { Position.Y = value; } }
            /// <summary>
            /// Gets or sets the Z coordinate of the vertex's position
            /// </summary>
            public float Z { get { return Position.Z; } set { Position.Z = value; } }
            /// <summary>
            /// Gets the vertex's format
            /// </summary>
            public static readonly VertexFormat Format = VertexFormat.Position;
            /// <summary>
            /// Gets the amount of memory the vertex consumes in bytes
            /// </summary>
            public static int SizeInBytes { get { return Marshal.SizeOf(typeof(CustomVertex.PositionOnly)); } }
            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="position">The 3D position of the vertex</param>
            public PositionOnly(Vector3 position) { Position = position; }
        }
    }
}  
